jq 'if .mode then if .mode != 3 then empty else . end else . end'|jq 'paths as $path|(.device|split("/")) as $dev|(if .class == "GST" then ([$dev[2],"gst"]|join("/")) else $dev[2] end) as $gst|{($gst):(({(if(($path|length)==2) then [$path[0],($path[1]|tostring),$path[2]]|join("/") else if(($path|length)==1) then $path[0] else empty end end):getpath($path)}|if(.satellites or .device or .class or .status or .mode) then empty else . end|if($path[0] == "satellites") then {((["sat",(.[].PRN|tostring)])|join("/")):(.[]|del(.PRN))} else . end))}' |jq -rs 'reduce .[] as $item ({}; . * $item)'|jq -c 'leaf_paths as $path | {($path|join("/")):getpath($path)}'|jq -rs -c 'reduce .[] as $item ({}; . * $item)'|sed -e 's/{}//g'
